<?php
//简单管理页面范例，在你的管理页面引用coresection/checkA.php就OK，当然，不要忘了添加注销登录的链接
include_once '../common/script/check_session.php';
?>

<? $system_part = $_REQUEST ['sys_part']; ?>

<?
include_once("../../config_controller.php");
$host = $_SERVER['HTTP_HOST']; //取得进入所输入的域名
$theme_folder = host_theme($host);

include_once '../../front/' . $theme_folder . '/connection.php';include_once '../common/script/check_session.php';

?>

<?php include_once("function.php"); ?>
<?php include "../../front/" . $theme_folder . "/config.php"; ?>

<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/script/site-function.php"); ?>
<?php
include_once("term-list-function.php");
include_once (ROOT_PATH_."/function/get_cat_child.php");

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include_once('../modules/head.php'); ?>


    <style>
        .weixin-miniapp-code{
            display: none;
        }
    </style>


</head>











<body>

<div id="topbar">
    <!--TopBar端點01-->
    <?php include '../modules/topbar.php'; ?>
    <!--TopBar端點02-->
</div>

<div id="container">
<!--Container端點01-->
    <div id="maincontent" class="term-list">
<!--maincontent端點01-->

<div id="sidebar">
    <?php include '../modules/sidebar.php'; ?>
</div>




<div id="content">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend><h1><? echo $sys_title ?> 分类列表</h1></legend>
    </fieldset>




<div class="list-box <? echo $system_part ?>">



    <hr/>
    <div class="statistic">
        <?php include_once("../modules/term_btn.php");?>

        <div class="function">

            <div class="sort layui-form">
                <div class="layui-form-item" style="margin-bottom:5px;">
                    <label class="layui-form-label">排序：</label>
                    <div class="layui-input-block">
                        <select lay-filter="MM_jumpMenu">
                            <option value="">排序选择</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=listorder&&sortorder=desc&sys_part=<? echo $system_part ?>">人工排序降序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=listorder&&sortorder=asc&sys_part=<? echo $system_part ?>">人工排序升序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=nid&&sortorder=desc&sys_part=<? echo $system_part ?>">输入时间降序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=nid&&sortorder=asc&sys_part=<? echo $system_part ?>">输入时间升序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=name&&sortorder=desc&sys_part=<? echo $system_part ?>">资料名称升序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=name&&sortorder=asc&sys_part=<? echo $system_part ?>">资料名称降序</option>
                        </select>
                    </div>
                </div>
            </div>


        </div>


        <hr/>
    </div>


<style>
    .list-boxes .layui-table tr td .date span{padding-right: 15px;}
    .list-boxes .layui-table .name{margin-top: 15px;}
</style>

<div class="list-boxes term-list-box">


    <table class="layui-table layui-form">
        <colgroup>

            <col width="80">
            <col width="160">
            <col>
            <col width="175">
            <col width="145" class="status">
            <col width="100" class="publish">
            <col width="90" class="clickrate">
            <col width="80" class="amount">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>编号</th>
            <th  class="icon">图片</th>
            <th>分类名称</th>
            <th>顺序</th>
            <th>状态</th>
            <th>发布状态</th>
            <th>点击次数</th>
            <th>数据量</th>
            <!-- <th>资料</th> -->
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <?php

        for($i=0;$i<$term0num;$i++)
        {

			$cat_list = implode(',',get_cat_child($term0[$i]['nid'],$system_part));

			$result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");

			$now_product_number = mysql_fetch_assoc($result);

        ?>
        <tr>

            <td >
                <?echo $i+1 ?>
            </td>

            <td align="center"  class="icon">
                    <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term0[$i]['icon'] ?>" width="50"/>
                </td>
            <!-- 分类名称 -->
            <td>
                <a href="term-edit.php?nid=<?php echo $term0[$i]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term0[$i]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                    <span><?php echo $term0[$i]['name'] ?></span>
                </a>
            </td>



            <!--排序-->
            <td class="status">
                <li class="markorder bind-markorder" style="display:none">

                    <div class="addsub">
                        <div class="title">标记顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" class="input-counter" data-id="<?echo $term0[$i]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term0[$i]['markorder'] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>

                </li>
                <li class="listorder bind-listorder">
                    <div class="addsub">
                        <div class="title">列表顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" class="input-counter" data-id="<?echo $term0[$i]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term0[$i]['listorder'] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>


                </li>

            </td>





            <td>
                <ul>


                    <li class="recommend">
                        <label>推荐状态</label>
                        <input type="checkbox" name="term_recommend" value="<?php echo $term0[$i]['recommend'];?>"
                               id="<?php echo $term0[$i]['nid'];?>"
                               lay-skin="switch" lay-filter="filter"
                               lay-text="是|否" <?if ($term0[$i]['recommend'] == 1) { echo "checked"; }?> >
                    </li>



                    <li class="mark">
                        <label>标记状态</label>
                        <input type="checkbox" name="term_mark" value="<?php echo $term0[$i]['mark'];?>"
                               id="<?php echo $term0[$i]['nid'];?>"
                               lay-skin="switch" lay-filter="filter"
                               lay-text="是|否" <?if ($term0[$i]['mark'] == 1) { echo "checked"; }?> >
                    </li>





                </ul>
            </td>



            <!-- 发布状态 -->

            <td class="publish">
                <li >
                    <input type="checkbox" name="term_publish" value="<?php echo $term0[$i]['publish'];?>"
                           lay-skin="switch" lay-filter="filter"
                           id="<?php echo $term0[$i]['nid'];?>"
                           lay-text="发布|隐藏" <?if ($term0[$i]['publish'] == 1) { echo "checked"; }?> >
                </li>

            </td>


            <!-- 点击次数 -->
            <td>
                <span class="clickrate">
                    <? echo $term0[$i]['clickrate'] ?>
                </span>
            </td>
            <!-- 产品数量 -->
            <td>
                <span class="product_number">
                    <a href=" detail-list.php?sys_part=<? echo $system_part ?>&nid=<?php echo $term0[$i]['nid'] ?>">
                        <? echo $now_product_number['number'] ;?>
                    </a>
                </span>
            </td>

            <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term0[$i]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term0[$i]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if( $term0[$i]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term0[$i]['modifytime'] ?>
                </span>
                <?php }?>
                <span class="publish <? if($term0[$i]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term0[$i]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>
                <span class="clickrate">
                    <label>点击次数：</label><? echo $term0[$i]['clickrate'] ?>
                </span>
                <span class="product_number">
                    <label>产品数量：</label>

                    <a href=" detail-list.php?sys_part=product&nid=<?php echo $term0[$i]['nid'] ?>">

					<?
					echo $now_product_number['number'] ;
					?>
                    </a>
                </span>
</div>
            </td> -->

            <td>

                <a  class="delete layui-btn  layui-btn-sm"  <?php if($term0[$i]['is_disabled'] == 1 || $now_product_number['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term0[$i]['nid'].'&sys_part='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                <a href="term-edit.php?nid=<?php echo $term0[$i]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                <a class="weixin-miniapp-code layui-btn  layui-btn-sm" onclick="getWXCode(this)" data-nid="<?php echo $term0[$i]['nid'] ?>" data-name="<?php echo $term0[$i]['name'] ?>"> <i class="layui-icon">&#xe677;</i> 小程序码</a>
                <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
            </td>
        </tr>

         <?

        //设置需要搜索的表格的前缀后缀
        $table_Suffix=$sys_term_table;
        $table=$table_Prefix.$table_Suffix;
        //设置需要搜索的表格的前缀后缀


        //设置需要搜索的表格的排序项和升降项
        $sort_by = "nid";
        $sort_order = "desc";
        //设置需要搜索的表格的排序项和升降项

        ?>
         <?

        $query2 = mysql_query("SELECT COUNT(nid) FROM $table where term1 = ".$term0[$i]['nid']." && interm = 'term1' and belong = '$sys_belong'");
        $term1sum = mysql_result($query2, 0);

        if ($_REQUEST ['sortby'])
        {
            $sort_by = $_REQUEST ['sortby'];
        }

        $result1 = mysql_query("select * from $table where term1 = ".$term0[$i]['nid']." && interm = 'term1' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

		$term1 = array();
        while($row1 = mysql_fetch_assoc($result1))
        {
          	$term1[] = $row1;
            $term1_icon[$i][]=$row1['icon'];

        }


        ?>
        <?php



		for($ii=0;$ii<$term1sum;$ii++){

			$cat_list = implode(',',get_cat_child($term1[$ii]['nid'],$system_part));

			$result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");

			$now_product_number2 = mysql_fetch_assoc($result);

		?>
        <tr>
        <td ><?echo ($i+1).'-'.($ii+1) ?></td>
             <td align="center"  class="icon">
                    <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term1[$ii]['icon'] ?>" width="50"/>
                </td>

                <!-- 分类名称 -->
                <td>
                    <a href="term-edit.php?nid=<?php echo $term1[$ii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term1[$ii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?></span>
                    </a>
                </td>





            <!--排序-->
            <td class="status">
                <li class="markorder bind-markorder" style="display:none">

                    <div class="addsub">
                        <div class="title">标记顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" class="input-counter" data-id="<?echo $term1[$ii]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term1[$ii]['markorder'] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>

                </li>
                <li class="listorder bind-listorder">
                    <div class="addsub">
                        <div class="title">列表顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" class="input-counter" data-id="<?echo $term1[$ii]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term1[$ii]['listorder'] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>


                </li>

            </td>




            <td>
                <ul>


                    <li class="recommend">
                        <label>推荐状态</label>
                        <input type="checkbox" name="term_recommend" value="<?php echo $term1[$ii]['recommend'];?>"
                               id="<?php echo $term1[$ii]['nid'];?>"
                               lay-skin="switch" lay-filter="filter"
                               lay-text="是|否" <?if ($term1[$ii]['recommend'] == 1) { echo "checked"; }?>
                    </li>



                    <li class="mark">
                        <label>标记状态</label>
                        <input type="checkbox" name="term_mark" value="<?php echo $term1[$ii]['mark'];?>"
                               id="<?php echo $term1[$ii]['nid'];?>"
                               lay-skin="switch" lay-filter="filter"
                               lay-text="是|否" <?if ($term1[$ii]['mark'] == 1) { echo "checked"; }?>
                    </li>





                </ul>
            </td>



                <!-- 发布状态 -->

            <td class="publish">

                <input type="checkbox" name="term_publish" value="<?php echo $term1[$ii]['publish'];?>"
                       lay-skin="switch" lay-filter="filter"
                       id="<?php echo $term1[$ii]['nid'];?>"
                       lay-text="发布|隐藏" <?if ($term1[$ii]['publish'] == 1) { echo "checked"; }?>

            </td>

                <!-- 点击次数 -->
                <td>
                    <span class="clickrate">
                        <? echo $term1[$ii]['clickrate'] ?>
                    </span>
                </td>
                <!-- 产品数量 -->
                <td>
                    <span class="product_number">
                        <a href=" detail-list.php?sys_part=product&nid=<?php echo $term1[$ii]['nid'] ?>">
                            <?  echo $now_product_number2['number'] ;?>
                        </a>
                    </span>
                </td>

            <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term1[$ii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term1[$ii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if($term1[$ii]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term1[$ii]['modifytime'] ?>
                </span>
                <?php }?>
                <span class="publish <? if($term1[$ii]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term1[$ii]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>
                <span class="clickrate">
                    <label>点击次数：</label><? echo $term1[$ii]['clickrate'] ?>
                </span>
                <span class="product_number">
                    <label>产品数量：</label>
                    <a href=" detail-list.php?sys_part=product&nid=<?php echo $term1[$ii]['nid'] ?>">

					<?
					echo $now_product_number2['number'] ;
					?>
                    </a>

                </span>
</div>
            </td> -->

            <td>

                <a  class="delete layui-btn  layui-btn-sm"  <?php if($term1[$ii]['is_disabled'] == 1 || $now_product_number2['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term1[$ii]['nid'].'&sys_part='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                <a href="term-edit.php?nid=<?php echo $term1[$ii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
            </td>
        </tr>
        	<?

			$term1idnow=$term1[$ii]['nid'];

			$query = mysql_query("SELECT COUNT(nid) FROM $table where term2 = $term1idnow && interm = 'term2' and belong = '$sys_belong'" );
			$term2sum = mysql_result($query, 0);


			$result2 = mysql_query("select * from $table where term2= $term1idnow && interm = 'term2' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

			$term2 = array();
			while($row2 = mysql_fetch_assoc($result2))
			{

				$term2_icon[]=$row2['icon'];
				$term2[]=$row2;

			}

			?>
             <?php
			 for($iii=0;$iii<$term2sum;$iii++){
			 	$cat_list = implode(',',get_cat_child($term2[$iii]['nid'] ,$system_part));

				$result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");

				$now_product_number3 = mysql_fetch_assoc($result);
			 ?>
            <tr>
            <td ><?echo ($i+1).'-'.($ii+1).'-'.($iii+1) ?></td>
             <td align="center">
                    <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term2[$i]['icon'] ?>" width="50"/>
                </td>

                <!-- 分类名称 -->
                <td>
                    <a href="term-edit.php?nid=<?php echo $term2[$iii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term2[$iii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?> - <?php echo $term2[$iii]['name'] ?></span>
                    </a>
                </td>
                <!--排序-->
                <td class="status">
                    <li class="markorder bind-markorder" style="display:none">

                        <div class="addsub">
                            <div class="title">标记顺序</div>
                            <button type="button" class="btn-add">
                                +
                            </button>
                            <input type="text" class="input-counter" data-id="<?echo $term2[$iii]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term2[$iii]['markorder'] ?>">
                            <button type="button" class="btn-subtract">
                                -
                            </button>
                        </div>

                    </li>
                    <li class="listorder bind-listorder">
                        <div class="addsub">
                            <div class="title">列表顺序</div>
                            <button type="button" class="btn-add">
                                +
                            </button>
                            <input type="text" class="input-counter" data-id="<?echo $term2[$iii]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term2[$iii]['listorder'] ?>">
                            <button type="button" class="btn-subtract">
                                -
                            </button>
                        </div>


                    </li>

                </td>


                <td>
                    <ul>
                        <li class="recommend">
                            <label>推荐状态</label>
                            <input type="checkbox" name="term_recommend" value="<?php echo $term2[$iii]['recommend'];?>"
                                   id="<?php echo $term2[$iii]['nid'];?>"
                                   lay-skin="switch" lay-filter="filter"
                                   lay-text="是|否" <?if ($term2[$iii]['recommend'] == 1) { echo "checked"; }?>
                        </li>
                        <li class="mark">
                            <label>标记状态</label>
                            <input type="checkbox" name="term_mark" value="<?php echo $term2[$iii]['mark'];?>"
                                   id="<?php echo $term2[$iii]['nid'];?>"
                                   lay-skin="switch" lay-filter="filter"
                                   lay-text="是|否" <?if ($term2[$iii]['mark'] == 1) { echo "checked"; }?>
                        </li>
                    </ul>
                </td>



                <!-- 发布状态 -->
                <td class="publish">
                    <input type="checkbox" name="term_publish" value="<?php echo $term2[$iii]['publish'];?>"
                           lay-skin="switch" lay-filter="filter"
                           id="<?php echo $term2[$iii]['nid'];?>"
                           lay-text="发布|隐藏" <?if ($term2[$iii]['publish'] == 1) { echo "checked"; }?>

                </td>
                <!-- 点击次数 -->
                <td>
                    <span class="clickrate">
                        <? echo $term2[$iii]['clickrate'] ?>
                    </span>
                </td>
                <!-- 产品数量 -->
                <td>
                    <span class="product_number">
                        <a href=" detail-list.php?sys_part=product&nid=<?php echo $term2[$iii]['nid'] ?>">
                            <?  echo $now_product_number3['number'] ; ?>
                        </a>
                    </span>
                </td>

            <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term2[$iii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term2[$iii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?> - <?php echo $term2[$iii]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if( $term2[$iii]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term2[$iii]['modifytime'] ?>
                </span>
                <?php }?>

                <span class="publish <? if($term2[$iii]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term2[$iii]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>

                <span class="clickrate">
                    <label>点击次数：</label><? echo $term2[$iii]['clickrate'] ?>
                </span>

                <span class="product_number">
                    <label>产品数量：</label>
                    <a href=" detail-list.php?sys_part=product&nid=<?php echo $term2[$iii]['nid'] ?>">

					<?
					echo $now_product_number3['number'] ;
					?>
                    </a>
                </span>

</div>
            </td> -->

            <td>

                <a  class="delete layui-btn  layui-btn-sm"  <?php if($term2[$iii]['is_disabled'] == 1 || $now_product_number3['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term2[$iii]['nid'].'&sys_part='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                <a href="term-edit.php?nid=<?php echo $term2[$iii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                <a class="weixin-miniapp-code layui-btn  layui-btn-sm" onclick="" data-nid="<?php echo $detail_nid[$i] ?>" data-name="<?php echo $detail_name[$i] ?>"> <i class="layui-icon">&#xe677;</i> 小程序码</a>
                <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
            </td>
        </tr>

                 <?

                 $term3idnow=$term2[$iii]['nid'];

                 $query = mysql_query("SELECT COUNT(nid) FROM $table where term2 = $term3idnow && interm = 'term3' and belong = '$sys_belong'" );
                 $term3sum = mysql_result($query, 0);


                 $result3 = mysql_query("select * from $table where term2= $term3idnow && interm = 'term3' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

                 $term3 = array();
                 while($row3 = mysql_fetch_assoc($result3))
                 {

                     $term3_icon[]=$row3['icon'];
                     $term3[]=$row3;

                 }

                 ?>
                 <?php
                 for($iiii=0;$iiii<$term3sum;$iiii++){
                     $cat_list = implode(',',get_cat_child($term3[$iiii]['nid'] ,$system_part));

                     $result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");

                     $now_product_number3 = mysql_fetch_assoc($result);
                     ?>
                     <tr>
                         <td ><?echo ($i+1).'-'.($ii+1).'-'.($iii+1) ?></td>
                         <td align="center">
                             <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term2[$i]['icon'] ?>" width="50"/>
                         </td>

                         <!-- 分类名称 -->
                         <td>
                             <a href="term-edit.php?nid=<?php echo $term3[$iiii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term3[$iiii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                                 <span><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?> - <?php echo $term3[$iiii]['name'] ?></span>
                             </a>
                         </td>
                         <!--排序-->
                         <td class="status">
                             <li class="markorder bind-markorder" style="display:none">

                                 <div class="addsub">
                                     <div class="title">标记顺序</div>
                                     <button type="button" class="btn-add">
                                         +
                                     </button>
                                     <input type="text" class="input-counter" data-id="<?echo $term3[$iiii]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term3[$iiii]['markorder'] ?>">
                                     <button type="button" class="btn-subtract">
                                         -
                                     </button>
                                 </div>

                             </li>
                             <li class="listorder bind-listorder">
                                 <div class="addsub">
                                     <div class="title">列表顺序</div>
                                     <button type="button" class="btn-add">
                                         +
                                     </button>
                                     <input type="text" class="input-counter" data-id="<?echo $term3[$iiii]['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $term3[$iiii]['listorder'] ?>">
                                     <button type="button" class="btn-subtract">
                                         -
                                     </button>
                                 </div>


                             </li>

                         </td>


                         <td>
                             <ul>
                                 <li class="recommend">
                                     <label>推荐状态</label>
                                     <input type="checkbox" name="term_recommend" value="<?php echo $term3[$iiii]['recommend'];?>"
                                            id="<?php echo $term3[$iiii]['nid'];?>"
                                            lay-skin="switch" lay-filter="filter"
                                            lay-text="是|否" <?if ($term3[$iiii]['recommend'] == 1) { echo "checked"; }?>
                                 </li>
                                 <li class="mark">
                                     <label>标记状态</label>
                                     <input type="checkbox" name="term_mark" value="<?php echo $term3[$iiii]['mark'];?>"
                                            id="<?php echo $term3[$iiii]['nid'];?>"
                                            lay-skin="switch" lay-filter="filter"
                                            lay-text="是|否" <?if ($term3[$iiii]['mark'] == 1) { echo "checked"; }?>
                                 </li>
                             </ul>
                         </td>



                         <!-- 发布状态 -->
                         <td class="publish">
                             <input type="checkbox" name="term_publish" value="<?php echo $term3[$iiii]['publish'];?>"
                                    lay-skin="switch" lay-filter="filter"
                                    id="<?php echo $term3[$iiii]['nid'];?>"
                                    lay-text="发布|隐藏" <?if ($term3[$iiii]['publish'] == 1) { echo "checked"; }?>

                         </td>
                         <!-- 点击次数 -->
                         <td>
                    <span class="clickrate">
                        <? echo $term3[$iiii]['clickrate'] ?>
                    </span>
                         </td>
                         <!-- 产品数量 -->
                         <td>
                    <span class="product_number">
                        <a href=" detail-list.php?sys_part=product&nid=<?php echo $term3[$iiii]['nid'] ?>">
                            <?  echo $now_product_number3['number'] ; ?>
                        </a>
                    </span>
                         </td>

                         <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term3[$iiii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term3[$iiii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?> - <?php echo $term3[$iiii]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if( $term3[$iiii]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term3[$iiii]['modifytime'] ?>
                </span>
                <?php }?>

                <span class="publish <? if($term3[$iiii]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term3[$iiii]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>

                <span class="clickrate">
                    <label>点击次数：</label><? echo $term3[$iiii]['clickrate'] ?>
                </span>

                <span class="product_number">
                    <label>产品数量：</label>
                    <a href=" detail-list.php?sys_part=product&nid=<?php echo $term3[$iiii]['nid'] ?>">

					<?
                         echo $now_product_number3['number'] ;
                         ?>
                    </a>
                </span>

</div>
            </td> -->

                         <td>

                             <a  class="delete layui-btn  layui-btn-sm"  <?php if($term3[$iiii]['is_disabled'] == 1 || $now_product_number3['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term3[$iiii]['nid'].'&sys_part='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                             <a href="term-edit.php?nid=<?php echo $term3[$iiii]['nid'] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                             <a class="weixin-miniapp-code layui-btn  layui-btn-sm" onclick="" data-nid="<?php echo $detail_nid[$i] ?>" data-name="<?php echo $detail_name[$i] ?>"> <i class="layui-icon">&#xe677;</i> 小程序码</a>
                             <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
                         </td>
                     </tr>
                     <?php
                 }
			}
		}

	} ?>

	 	</tbody>
    </table>

</div>


<div class="list-box-function" <? if ($term0num==0){echo "style"."='display:none'";} ?> >
    <div class="page-guide">

        <?php
        if($nowpageid==1)
        {
            ?>
            <!--现在页数在第一页的时候-->
            <span>首页</span>
            <span>前一页</span>
            <!--现在页数非第一页的时候-->
        <?php
        }
        else
        {
            ?>
            <!--现在页数非第一页的时候-->
            <a href="term-list.php?sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>">首页</a>
            <a href="term-list.php?nowpageid=<?php echo $prepage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>">前一页</a>
            <!--现在页数非第一页的时候-->
        <?php
        }
        ?>


        <!--开始列印出所有页码-->

        <?php
        $ii=1;
        $iii=1;
        while ($ii<=$page_count)
        {
            //首先判断是不是当前页

            if($ii==$nowpageid)
            {
                echo "<span>".$ii."</span>";
            }
            else if((($ii+5)<$nowpageid)||(($ii-5)>$nowpageid))
            {
            }
            else
            {
                echo "<a href='";
                echo "term-list.php?nowpageid=";
                echo $iii;
                echo "&sortby=";
                echo $sort_by;
                echo "&nid=";
                echo $trans_nid;
                echo "&sys_part=";
                echo $system_part;
                echo "'>";
                echo $iii;
                echo "</a>";
            }

            $ii++;
            $iii++;
        }
        ?>

        <!--列印出所有页码 结束-->


        <?php
        if($nowpageid==$page_count)
        {
            ?>
            <!--现在页数在第一页的时候-->
            <span>后一页</span>
            <span>末页</span>
            <!--现在页数非第一页的时候-->
        <?php
        }
        else
        {
            ?>
            <!--现在页数非第一页的时候-->
            <a href="term-list.php?nowpageid=<?php echo $nextpage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>">后一页</a>
            <a href="term-list.php?nowpageid=<?php echo $lastpage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>">末页</a>
            <!--现在页数非第一页的时候-->
        <?php
        }
        ?>




    </div>
    <!--翻页代码结束-->
</div>


<!--list-box end-->
</div>

<!--content端點01-->
</div>

<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>

<!--删除box-->
<?php include '../modules/deletebar.php'; ?>
<!--删除box end-->
<?php include  ROOT_PATH_."/controller/modules/footer.php"; ?>
<script>
    function getWXCode(e) {
        const nid = e.dataset.nid
        const name = e.dataset.name
        const domain = 'https://dj100.enpingshi.com/'
        $.ajax({
            method: 'GET',
            url: domain + 'api/dangjian100/get_qc_code.php',
            data: {
                path: '/pages/place-introduce/place-introduce',
                name,
                nid
            },
            contentType: 'application/json',
            success: res => {
                const obj = JSON.parse(res)
                if(obj.code == 0) {
                    window.open(domain + obj.data)
                }
            }
        })
    }



    //  环桥项目多语言term同步
    $('.huanqiao-sync-term').click(function() {
        const nid = this.dataset.nid
        console.log(this, nid)
        $(this).val('正在同步此分类')
        $('.huanqiao-sync-term').attr('disabled', 'disabled')
        $('.huanqiao-sync-term').addClass('layui-btn-disabled')
        syncData(0, nid)
    })

    const lan = ['ara', 'fra', 'jp', 'pl', 'pt', 'ru', 'spa', 'th', 'vie']
    function syncData(index, nid) {
        const btn = $('.huanqiao-sync-term')
        $.ajax({
            url: `/api/huanqiao/sync_datas.php?from=en&to=${lan[index]}&table=term&nid=${nid}`,
            success: function() {
                console.log('success: ', lan[index])
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log('erro: ', lan[index])
                console.log(XMLHttpRequest, textStatus, errorThrown)
            },
            complete: function() {
                if(index < lan.length-1) {
                    syncData(index+1, nid)
                }else{
                    btn.removeAttr('disabled')
                    btn.removeClass('layui-btn-disabled')
                    btn.attr('value', '同步此分类')
                }
            }
        })
    }


</script>
</body>
</html>
